namespace StyleCreator.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class NewFields : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Looks",
                c => new
                    {
                        LookID = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        Description = c.String(),
                        PublishDate = c.DateTime(),
                        IsPublic = c.Boolean(nullable: false),
                        Views = c.Int(nullable: false),
                        AuthorID = c.Guid(nullable: false),
                        Author_UserId = c.Guid(),
                        Category_CategoryID = c.Int(),
                    })
                .PrimaryKey(t => t.LookID)
                .ForeignKey("dbo.Users", t => t.Author_UserId)
                .ForeignKey("dbo.Categories", t => t.Category_CategoryID)
                .Index(t => t.Author_UserId)
                .Index(t => t.Category_CategoryID);
            
            CreateTable(
                "dbo.Tags",
                c => new
                    {
                        TagID = c.Int(nullable: false, identity: true),
                        TagText = c.String(),
                    })
                .PrimaryKey(t => t.TagID);
            
            CreateTable(
                "dbo.Categories",
                c => new
                    {
                        CategoryID = c.Int(nullable: false, identity: true),
                        CategoryName = c.String(),
                        IsPublic = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.CategoryID);
            
            CreateTable(
                "dbo.Comments",
                c => new
                    {
                        CommentID = c.Int(nullable: false, identity: true),
                        Author = c.Guid(nullable: false),
                        Text = c.String(),
                        IsReply = c.Boolean(nullable: false),
                        Date = c.DateTime(nullable: false),
                        LookID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.CommentID)
                .ForeignKey("dbo.Looks", t => t.LookID, cascadeDelete: true)
                .Index(t => t.LookID);
            
            CreateTable(
                "dbo.Items",
                c => new
                    {
                        ItemID = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Url = c.String(),
                        LookID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ItemID)
                .ForeignKey("dbo.Looks", t => t.LookID, cascadeDelete: true)
                .Index(t => t.LookID);
            
            CreateTable(
                "dbo.Photos",
                c => new
                    {
                        PhotoID = c.Int(nullable: false, identity: true),
                        PhotoLink = c.String(),
                        PhotoComment = c.String(),
                        LookID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.PhotoID)
                .ForeignKey("dbo.Looks", t => t.LookID, cascadeDelete: true)
                .Index(t => t.LookID);
            
            CreateTable(
                "dbo.Scores",
                c => new
                    {
                        ScoreID = c.Int(nullable: false, identity: true),
                        Author = c.Guid(nullable: false),
                        Fit = c.Int(nullable: false),
                        Hot = c.Int(nullable: false),
                        Trendy = c.String(),
                        Elegant = c.Int(nullable: false),
                        LookID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ScoreID)
                .ForeignKey("dbo.Looks", t => t.LookID, cascadeDelete: true)
                .Index(t => t.LookID);
            
            CreateTable(
                "dbo.Messages",
                c => new
                    {
                        MessageID = c.Int(nullable: false, identity: true),
                        Author = c.Int(nullable: false),
                        Destination = c.Int(nullable: false),
                        Subject = c.String(),
                        Text = c.String(),
                        IsReply = c.Boolean(nullable: false),
                        Date = c.DateTime(nullable: false),
                        UserID = c.Guid(nullable: false),
                    })
                .PrimaryKey(t => t.MessageID)
                .ForeignKey("dbo.Users", t => t.UserID, cascadeDelete: true)
                .Index(t => t.UserID);
            
            CreateTable(
                "dbo.TagLooks",
                c => new
                    {
                        Tag_TagID = c.Int(nullable: false),
                        Look_LookID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Tag_TagID, t.Look_LookID })
                .ForeignKey("dbo.Tags", t => t.Tag_TagID, cascadeDelete: true)
                .ForeignKey("dbo.Looks", t => t.Look_LookID, cascadeDelete: true)
                .Index(t => t.Tag_TagID)
                .Index(t => t.Look_LookID);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.TagLooks", new[] { "Look_LookID" });
            DropIndex("dbo.TagLooks", new[] { "Tag_TagID" });
            DropIndex("dbo.Messages", new[] { "UserID" });
            DropIndex("dbo.Scores", new[] { "LookID" });
            DropIndex("dbo.Photos", new[] { "LookID" });
            DropIndex("dbo.Items", new[] { "LookID" });
            DropIndex("dbo.Comments", new[] { "LookID" });
            DropIndex("dbo.Looks", new[] { "Category_CategoryID" });
            DropIndex("dbo.Looks", new[] { "Author_UserId" });
            DropForeignKey("dbo.TagLooks", "Look_LookID", "dbo.Looks");
            DropForeignKey("dbo.TagLooks", "Tag_TagID", "dbo.Tags");
            DropForeignKey("dbo.Messages", "UserID", "dbo.Users");
            DropForeignKey("dbo.Scores", "LookID", "dbo.Looks");
            DropForeignKey("dbo.Photos", "LookID", "dbo.Looks");
            DropForeignKey("dbo.Items", "LookID", "dbo.Looks");
            DropForeignKey("dbo.Comments", "LookID", "dbo.Looks");
            DropForeignKey("dbo.Looks", "Category_CategoryID", "dbo.Categories");
            DropForeignKey("dbo.Looks", "Author_UserId", "dbo.Users");
            DropTable("dbo.TagLooks");
            DropTable("dbo.Messages");
            DropTable("dbo.Scores");
            DropTable("dbo.Photos");
            DropTable("dbo.Items");
            DropTable("dbo.Comments");
            DropTable("dbo.Categories");
            DropTable("dbo.Tags");
            DropTable("dbo.Looks");
        }
    }
}
